// eslint-disable-next-line no-shadow
export function search({ pg, search } = {}) {
  return RSocket.rs({
    route: 'notifications',
    args: {
      pg,
      search,
    },
  });
}

// eslint-disable-next-line no-shadow
export function count({ search }) {
  return RSocket.rr({
    route: 'notifications.count',
    args: {
      search,
    },
  });
}

export function get(id) {
  return RSocket.rr({
    route: `notifications.${id}`,
  });
}

export function remove(id) {
  return RSocket.rr({
    route: `notifications.${id}.delete`,
  });
}

export function create(data) {
  return RSocket.rr({
    route: 'cbv.app.create',
    data: {
      ...data,
    },
  });
}

export function update(id) {
  return RSocket.rr({
    route: `notifications.${id}.markread`,
  });
}

/**
 * 监听通知
 * @param {*} id
 * @returns
 */
export function notifySubscribe(args) {
  return RSocket.rs({
    route: 'notifications.subscribe',
    ...args,
  });
}

// 获取字典项
export function getDict(dictId) {
  return RSocket.rs({
    route: `dicts.${dictId}.items`,
  });
}

// 获取字典项
export function getDictCount(dictId) {
  return RSocket.rr({
    route: `dicts.${dictId}.items.count`,
  });
}

// 修改字典项
export function dictUpdate(dictId, data) {
  return RSocket.rr({
    route: `dicts.${dictId}.items.update`,
    data: {
      ...data,
    },
  });
}

// 发送通知
export function sendNotify(args) {
  return RSocket.rr({
    route: 'commons.system.send',
    args: {
      ...args,
    },
  });
}

// 批量标记通知为已读
export function readAll(data) {
  return RSocket.rr({
    route: 'notifications.read.markread',
    data:
      [...data],
  });
}

// 标记当前用户所有通知为已读
export function myall() {
  return RSocket.rr({
    route: 'notifications.markread.myall',
  });
}

/**
 * 获取指定用户
 * @param {*} args
 */
export function getUserMobile(mobile) {
  return RSocket.rr({
    route: `users.bymobile.${mobile}`,
  });
}
